package com.kuang.demo.service.wx;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.kuang.demo.bean.WXFeedbackSubmit;
import com.kuang.demo.mapper.wx.WXFeedbackMapper;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class WXFeedbackServiceImpl implements WXFeedbackService {
    @Autowired
    WXFeedbackMapper feedbackMapper;

    @SneakyThrows
    @Override
    public void submit(WXFeedbackSubmit feedbackSubmit) {
        List<String> picUrls = feedbackSubmit.getPicUrls();
        ObjectMapper objectMapper = new ObjectMapper();
        String pic =objectMapper.writeValueAsString(picUrls);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String time = simpleDateFormat.format(new Date().getTime());
        feedbackMapper.insertSubmit(feedbackSubmit,pic,time);
    }
}
